<template>
	<view class="box">
		<view class="headerBox">
			<view class="header">
				<view class="information">
					<view>
						<view><text>会员</text>：{{data.userName}} </view>
						<view><text>填写日期</text>：{{data.fillFormDate}}</view>
					</view>
					<view>
						<view><text>性别</text>：{{userInfo.sex && userInfo.sex == 1 ? '男' : '女' || ''}} </view>
						<view><text>年龄</text>：{{userInfo.age}}</view>
					</view>
					<view>
						<view><text>评估人</text>：{{data.healthName}}</view>
						<view><text>评估日期</text>：{{data.modifiedDate ? data.modifiedDate : data.createdDate}}</view>
					</view>
				</view>
			</view>
			
			<view class="connectBox" v-show="!searchBarFixed">
				<image src="@/static/img/healthStatus/connect@2x.png"></image>
				<image src="@/static/img/healthStatus/connect@2x.png"></image>
			</view>
		</view>
		
		<view class="content1">
			<view class="modular1">
				<view class="title">一般检查</view>
				<table>
					<tr>
						<td>名称</td>
						<td>单位</td>
						<td>检测结果</td>
					</tr>
					<tr v-for="(item,index) in enterData" :key="index">
						<td>{{item.inputName}}</td>
						<td>{{item.inputCompany}}</td>
						<td v-if="item.inputName == '收缩压/舒张压'">
							{{bloodPressure1 ? bloodPressure1 : '未检测'}}/{{bloodPressure2 ? bloodPressure1 : '未检测'}}
						</td>
						<td v-else>
							{{data[item.name] ?data[item.name] : '未检测'}}
						</td>
					</tr>
				</table>
			</view>
			
			<view class="modular1">
				<view class="title">生化检查</view>
				<table>
					<tr>
						<td>名称</td>
						<td>单位</td>
						<td>检测结果</td>
					</tr>
					<tr v-for="(item,index) in biochemistry" :key="index">
						<td>{{item.inputName}}</td>
						<td v-if="item.inputName == '白细胞计数' || item.inputName == '红细胞计数' || item.inputName == '血小板计数'"><image mode="widthFix" src="@/static/img/healthStatus/icon-109.png" style="width:80rpx;"></image></td>
						<td v-else>{{item.inputCompany}}</td>
						<td v-if="item.inputName == '收缩压/舒张压'">
							{{bloodPressure1}}/{{bloodPressure2}}
						</td>
						<td v-else>
							{{data[item.name] == '-1'?'未检测':data[item.name]}}
						</td>
					</tr>
				</table>
			</view>
			
			<view class="modular1">
				<view class="title">辅助检查项目</view>
				<table>
					<tr>
						<td>检查项目</td>
						<td>检测结果</td>
					</tr>
					<tr v-for="(aitem,aindex) in auxiliaryData" :key="aindex">
						<td>{{aitem.name || '未填写检查项目'}}</td>
						<td>
							{{aitem.value && aitem.value != '-1' ? aitem.value : '未检测'}}
						</td>
					</tr>
					<!-- <tr v-for="(aitem,aindex) in parameterValues" :key="'b'+aindex">
						<td>
							{{aitem.name || '未填写检查项目'}}
						</td>
						<td class="delStyle">
							{{aitem.value && aitem.value != '-1' ? aitem.value : '未检测'}}
						</td>	
					</tr> -->
				</table>
			</view>
			
			<view class="modular1" v-if="isCheckDxData && isCheckDxData.length > 0">
				<view class="title">其他检查</view>
				<table>
					<tr v-if="isCheckDxData && isCheckDxData.length > 0">
						<td>名称</td>
						<td>单位</td>
						<td>检测结果</td>
					</tr>
					<tr v-if="isCheckDxData && isCheckDxData.length > 0" v-for="(bitem,bindex) in isCheckDxData" :key="bindex">
						<td>{{bitem.name}}</td>
						<td>{{bitem.units || '-'}}</td>
						<td>{{bitem.input}}</td>
					</tr>
				</table>
			</view>
		</view>
	</view>
</template>

<script>
	import {getUrlParam,distance,age} from '@/static/js/filter.js';
	export default{
		data() {
			return {
				userInfo:{},
				data:{},
				selected: '',
				examinationOrgan:'',
				dynamicData:[], //辅助项目添加其他
				bloodPressure1:'',
				bloodPressure2:'',
				enterData: [
					{
						inputName: '身高',
						inputCompany: 'cm',
						inputData: '',
						name: 'height'
					}, {
						inputName: '体重',
						inputCompany: 'kg',
						inputData: '',
						name: 'weight'
					}, {
						inputName: '体重指数',
						inputCompany: 'kg/m²',
						inputData: '',
						name: 'bodyIndex'
					}, {
						inputName: '腰围',
						inputCompany: 'cm',
						inputData: '',
						name: 'waist'
					}, {
						inputName: '收缩压/舒张压',
						inputCompany: 'mmHg',
						inputData: '',
						name: 'bloodPressure'
					}, {
						inputName: '心率',
						inputCompany: '次/分',
						inputData: '',
						name: 'heartRate'
					}
				],
				biochemistry: [
					{
						inputName: '总胆固醇',
						inputCompany: 'mmol/L',
						inputData: '',
						name: 'cholesterol'
					}, {
						inputName: '甘油三酯',
						inputCompany: 'mmol/L',
						inputData: '',
						name: 'triacylglycerol'
					}, {
						inputName: '高密度脂蛋白胆固醇',
						inputCompany: 'mmol/L',
						inputData: '',
						name: 'highCholesterol'
					}, {
						inputName: '低密度脂蛋白胆固醇',
						inputCompany: 'mmol/L',
						inputData: '',
						name: 'lowCholesterol'
					}, {
						inputName: '空腹血糖',
						inputCompany: 'mmol/L',
						inputData: '',
						name: 'bloodGlucose'
					}, {
						inputName: '餐后2小时血糖',
						inputCompany: 'mmol/L',
						inputData: '',
						name: 'towBloodGlucose'
					}, {
						inputName: '血尿酸',
						inputCompany: 'μmol/L',
						inputData: '',
						name: 'bloodUricAcid'
					}, {
						inputName: '谷丙转氨酶',
						inputCompany: 'U/L',
						inputData: '',
						name: 'aminotransferase'
					}, {
						inputName: '白细胞计数',
						inputCompany: '109/L',
						inputData: '',
						name: 'whiteCell'
					}, {
						inputName: '总胆红素',
						inputCompany: 'μmol/L',
						inputData: '',
						name: 'bilirubin'
					}, {
						inputName: '红细胞计数',
						inputCompany: '109/L',
						inputData: '',
						name: 'redCell'
					}, {
						inputName: '血尿素氮',
						inputCompany: 'mmol/L',
						inputData: '',
						name: 'bloodUreaNitrogen'
					}, {
						inputName: '血红蛋白',
						inputCompany: 'g/L',
						inputData: '',
						name: 'hemoglobin'
					}, {
						inputName: '血肌酐',
						inputCompany: 'μmol/L',
						inputData: '',
						name: 'bloodMuscle'
					}, {
						inputName: '血小板计数',
						inputCompany: '109/L',
						inputData: '',
						name: 'plateletCount'
					}],
					auxiliaryData: [{
						name: '心电图',
						value: ''
					}, {
						name: '腹部超声',
						value: ''
					}, {
						name: 'X线胸片',
						value: ''
					}
				],
				parameterValues:[], //添加辅助项目
				// 所有体检项目分页参数
				tiOption:{pageIndex:1,totalCount:0},
				abnormalName:'',
				// 异常体检表头
				dialogHeaders2:[{label: '科室',key:'sectionName'},{label: '名称',key:'name'},{label: '参考范围',key:'va'},{label: '单位',key:'units'}],
				dialogcontents: [],
				isCheckYcData:[], //选中的异常数据
				dialog: false,
				isCheckDxData:[], //选中的单项数据
				searchBarFixed: false,
			}
		},
		onLoad(option) {
			if(option.id) {
				this.$api.findByUserId(option.userId).then((res)=>{
					this.userInfo = res.data.result
				})
				this.$api.HealthExaminationReportDetails(option.id).then((res) => {
					if (res.data.returnCode == 200) {
						this.userId = res.data.result && res.data.result.newExaminationReportRes.userId;
						this.userName = res.data.result && res.data.result.newExaminationReportRes.userName;
						this.organ = res.data.result && res.data.result.newExaminationReportRes.organ;
						this.examinationDate = res.data.result && res.data.result.newExaminationReportRes.examinationDate;
						this.data = res.data.result.newExaminationReportRes;
						this.bloodPressure1 = res.data.result.newExaminationReportRes.bloodPressure == '-1' ? '' : res.data.result.newExaminationReportRes
							.bloodPressure.split('/')[0]
						this.bloodPressure2 = res.data.result.newExaminationReportRes.bloodPressure == '-1' ? '' : res.data.result.newExaminationReportRes
							.bloodPressure.split('/')[1]
						this.auxiliaryData = res.data.result.newExaminationReportRes.auxiliaryExamination && JSON.parse(res.data.result
							.newExaminationReportRes.auxiliaryExamination).map((a) => {
							if (a.value == -1) {
								a.value = ''
							}
							return a
						});
						this.isCheckDxData = res.data.result && res.data.result.newExaminationReportRes.individuals.length > 0 && res.data
							.result.newExaminationReportRes.individuals.map((a) => {
								a.input = a.value;
								a.itemName = a.name;
								a.itemId = a.key;
								return a
							}) || [];
						this.enterData.map((a, ai) => {
							if (res.data.result.newExaminationReportRes[a.name]) {
								if (res.data.result.newExaminationReportRes[a.name] == -1) {
									res.data.result.newExaminationReportRes[a.name] = ''
								}
								a.dataId = ai + ''
							}
							return a
						})
					}
				})
			}
		},
		onPageScroll() {
			this.searchBarFixed = this.distance('content1');
		},
		methods:{
			age,
			distance,
			question() {
				return new Promise((success,error)=>{
					this.$api.findByTopicsType('ids=25&ids=26').then((res)=>{
						if(res){
							const aArr = res.data.result[25] && res.data.result[25].adTopicsRepliesEntityList.map((a)=>{
								a.adTopicsRepliesEntityList = a.adTopicsRepliesEntityList.map((b)=>{b.checked = false;return b})
								return a
							})
							const bArr = res.data.result[26] && res.data.result[26].adTopicsRepliesEntityList.map((a)=>{
								a.adTopicsRepliesEntityList = a.adTopicsRepliesEntityList.map((b)=>{b.checked = false;return b})
								return a
							})
							this.psychologyQuestion = aArr.concat(bArr)
							success(res.data.result)
						}else{
							error('')
						}
					})
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/static/css/quickly/healthStatus/toView.scss';
	@import '@/static/css/quickly/healthStatus/common.scss';
	.content1 {
		margin-top: 268upx;
		padding-top: 24upx;
		.modular1 {
			width: 702upx;
			margin: 0 auto 24upx;
			background-color: #FFFFFF;
			border-radius: 14upx;
			box-sizing: border-box;
			.title {
				padding: 28upx 0;
				color: #05C6AD;
				font-size: 34upx;
				text-align: center;
				font-weight: bold;			
			}
			table {
				width: 702upx;
				border-spacing: 0 !important;
				tr {
					background-color: #FFFFFF;
					display: flex;
					padding: 16upx 0;
					box-sizing: border-box;
					text-align: center;
					border-bottom: 1upx solid #E3E4EB;
					margin: 0 8upx;
					td {
						color: #333333;
						display: flex;
						justify-content: center;
						align-items: center;
						flex: 1;
						text-align: center;
						min-height: 60upx;
						input {
							width: 100%;
							font-size: 28upx;
							height: 100%;
						}
					}
					td:last-child {
						border: 0;
					}
				}
				tr:nth-child(1) {
					background-color: #F6F7FB;
					box-sizing: border-box;
					border-radius: 12upx;
					border: none;
				}
				tr:last-child {
					border: none;
				}
				.delImage {
					width: 22upx;
					height: 24upx;
					margin: auto 24upx auto 8upx;
				}
				.delStyle {
					display: flex;
				}
				.addOther {
					width: 686upx;
					height: 60upx;
					line-height: 60upx;
					text-align: center;
					border-radius: 12upx;
					color: #A8B2D1;
					font-size: 26upx;
					margin: 0 8upx;
					image {
						width: 26upx;
						height: 26upx;
						margin-right: 14upx;
						vertical-align: revert;
					}
				}
			}
		}
		.modular:last-child {
			padding-bottom: 36upx;
		}
	}

</style>
